Array.prototype.MyMap = function (callback, thisArg) {
    if (typeof callback !== 'function') {
        throw new TypeError('传递的callback不是一个方法')
    }
    if (this == undefined) {
        throw new TypeError('调用出错了')
    }
    const res = [];
    // console.log(this);
    const O = Object(this);

    let len = O.length;
    for (let i = 0; i < len; i++) {
        if (i in O) {
            res[i] = callback.call(thisArg, O[i], i, this)
        }
    }
    return res;
}
const array1 = [1, 4, 9, 16];
const map1 = array1.MyMap(x => x * 2);

console.log(map1);